<?php
class helpController extends Web_Controller_Base
{
    public function indexAction()
    {
        $this->aboutusAction();
    }

    public function aboutusAction()
    {
        $this->setData('title', '关于本站');
        $this->setData('menu', 'aboutus');
        $this->setView('Help/aboutus.tpl');
    }
    
    public function feedbackAction()
    {
        $this->setData('title', '意见反馈');
        $this->setData('menu', 'feedback');
        $this->setView('Help/feedback.tpl');
    }
    
    public function feebackAjaxAction()
    {
        $content = $this->getPost('content', '');
        $code = $this->getPost('code', '');
        $ret['errCode'] = 0;
        $ret['errMsg']  = 'success';
        if(Web_Model_AuthCode::veify($code)){
            try {
                $id = Web_Model_Feedback::add($content);
            }catch (Eren_DB_Exception $e){
                $ret['errCode'] = -10;
                $ret['errMsg']  = '系统异常，稍后重试';
            }catch (Exception $e){
                $ret['errCode'] = $e->getCode();
                $ret['errMsg']  = $e->getMessage();
            }
        }else{
            $ret['errCode'] = -10;
            $ret['errMsg']  = '验证码不正确';
        }
        echo json_encode($ret);
    }
    
    public function helpAction()
    {
        $this->setData('title', '帮助信息');
        $this->setData('menu', 'help');
        $this->setView('Help/help.tpl');
    }
}